package com.bjpowernode.ba02;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component("mystudent")
public class Student {

    /*
    * @Value:给简单类型属性赋值
    *   属性：value 是String类型，表示简单类型的属性值
    *   位置: 1.在属性定义的上面。无需set方法
    *         2.在set方法上面
    * */
    @Value(value = "李红磊")//也可以是@Value("李红磊")  省略value
    private String name;

    @Value(value = "21")
    private Integer age;


    public Student() {
        System.out.println("无参构造");
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
